#!/bin/bash

#echo "testing characteristic type $1"
ct=6

set -x

for imgname in testscreensmallgrey lenna barbara 
do
  contextencode -ct $ct -cf goodcc/lennagtw.ctd -e 0 ../images/$imgname.pgm temp/temp.bits
  if [ -a goodbits/${imgname}gtw.bits ] # if file exists
  then  cmp temp/temp.bits goodbits/${imgname}gtw.bits
  else  echo "**Creating goodbits/${imgname}gtw.bits"
        mv temp/temp.bits goodbits/${imgname}gtw.bits
  fi 
  echo ""
done

for imgname in testscreen testscreensmall
do
  contextencode -ct $ct -cf goodcc/lennagtw.ctd -e 0 ../images/$imgname.ppm temp/temp.bits
  if [ -a goodbits/${imgname}gtw.bits ] # if file exists
  then  cmp temp/temp.bits goodbits/${imgname}gtw.bits
  else  echo "**Creating goodbits/${imgname}gtw.bits"
        mv temp/temp.bits goodbits/${imgname}gtw.bits
  fi 
  echo ""
done

for imgname in lenna
do
  contextencode -ct $ct -cf goodcc/lennagtw.ctd -e 0 -s 4 ../images/$imgname.pgm temp/temp.bits
  if [ -a goodbits/${imgname}gtws4.bits ] # if file exists
  then  cmp temp/temp.bits goodbits/${imgname}gtws4.bits
  else  echo "**Creating goodbits/${imgname}gtws4.bits"
        mv temp/temp.bits goodbits/${imgname}gtws4.bits
  fi 
  echo ""
done

for imgname in lenna
do
  contextencode -ct 1 -cf goodcc/lenna1greedy.ctd -e 0 -s 8 ../images/$imgname.pgm temp/temp.bits
  if [ -a goodbits/${imgname}1s8greedy.bits ] # if file exists
  then  cmp temp/temp.bits goodbits/${imgname}1s8greedy.bits
  else  echo "**Creating goodbits/${imgname}1s8greedy.bits"
        mv temp/temp.bits goodbits/${imgname}1s8greedy.bits
  fi 
  echo ""
done


